package com.ttg.utils.connection.handler;

//~--- non-JDK imports --------------------------------------------------------

import com.ttg.utils.Assert;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

//~--- JDK imports ------------------------------------------------------------

/**
 * Class	ParamsAndFileHttpResponse
 * Description	
 * Create	2015.09.11 at 01:26:14 CST
 * @author	Ardy    
 */
public class ParamsAndFileHttpResponse extends BaseHttpResponse {

    /** 
     * Field serialVersionUID
     * Description 
     */
    private static final long serialVersionUID = -7870994308137231081L;

    /** 
     * Field byteResult
     * Description 
     */
    private byte[] byteResult;

    /** 
     * Field downlaodFile
     * Description 
     */
    private File downlaodFile;

    /**
     * Constructs	ParamsAndFileHttpResponse
     * Description
     *
     * @param charset
     */
    public ParamsAndFileHttpResponse(Charset charset) {
        super(charset);
    }

    /**
     * Method getByteResult
     * Description
     * @return	byte[]
     */
    public byte[] getByteResult() {
        return (this.byteResult != null)
               ? this.byteResult
               : null;
    }

    /**
     * Method setByteResult
     * Description
     *
     * @param	byteResult byte[]
     */
    void setByteResult(byte[] byteResult) {
        Assert.notNull(byteResult, "[Assertion failed] - this argument[byteResult] is required; it must not be null");
        this.byteResult = byteResult;
    }

    /**
     * Method getStringResult
     * Description
     * @return	String
     *
     * @throws UnsupportedEncodingException
     */
    public String getStringResult() throws UnsupportedEncodingException {
        return (this.byteResult != null)
               ? new String(this.byteResult, this.getCharset().name())
               : null;
    }

    /**
     * Method getDownlaodFile
     * Description
     * @return	File
     */
    public File getDownlaodFile() {
        return this.downlaodFile;
    }

    /**
     * Method setDownlaodFile
     * Description
     *
     * @param	downlaodFile File
     */
    public void setDownlaodFile(File downlaodFile) {
        Assert.notNull(downlaodFile,
                       "[Assertion failed] - this argument[downlaodFile] is required; it must not be null");
        this.downlaodFile = downlaodFile;
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
